{literal}
<h2>Annotation</h2>
<br>
<b>@orm has|owns one|child|parent $className [inverse $inverse]<br></b>
<br>
<table cellspacing="2" cellpadding="2">
	<tr>
		<td>has</td>
		<td> Means that element is related to another object.</td>
	</tr>
	<tr>
		<td>owns</td>
		<td>Same as has, but when object is deleted it will also delete its related object</td>
	</tr>
	<tr>
		<td>child / one</td>
		<td> Means that related object is considered as child. On database level related object ID is stored into child table.</td>
	</tr>
	<tr>
		<td>parent</td>
		<td> Means that related object is considered parent.</td>
	</tr>
	<tr>
		<td>inverse</td>
		<td>Inverse relationship is this kind relationship where parent knows about its child and child knows about its parent.</td>
	</tr>
</table>

All relations must have parent and child side. You can't make both parts as child nor parent!


<h2> Simple 0ne to one relation </h2>
<pre class="code">
&lt;?php
class MyParent extends DomArObject {
	/**
	* @orm owns child MyChild inverse parent 
	*/
	private $child;		
}
			
class MyChild extends DomArObject {				
	/**
	* @orm has parent MyParent inverse child
	*/
	private $parent;			
}
?&gt;
</pre>
<h3>Using</h3>
<pre class="code">
&lt;?php
$parent = new MyParent();
$parent->child = new MyChild();

// saving parent and child
$parent->save();

//Accessing child
$parent = MyParent::load( $id );
$child = $parent->child;

//Accessing parent through child
$child = MyChild::load( $id );
$parent = $child->parent;

//Deleting parent and child
$parent->delete();
?&gt;
</pre>

<h2>Listeners and validator</h2>
<pre class="code">
&lt;?php
class MyClass extends DomArObject {
	
	/**
	* @orm has child SomeClass inverse someProperty
	* @orm listener beforeSet beforeSetChild
	* @orm validator method validateChild
	*/
	public $child;
	
	public function beforeSetChild( $child ) {
	
	}
	
	public function validateChild( $child ) {
		return 0;
	}
}
?&gt;
</pre>

{/literal}